﻿using System;
//using System.Linq;
using System.Collections.Generic;
using System.Text;
using Microsoft.WindowsMobile.PocketOutlook;
using System.Collections;

namespace Synchro
{
    public class Outlook
    {
        private OutlookSession _appSession;

        public Outlook()
        {
            _appSession = new OutlookSession();
        }

        public AppointmentCollection getAppointments()
        {
            //ArrayList appointments = new ArrayList();
            AppointmentCollection appCol = _appSession.Appointments.Items;
            /*foreach (Appointment appt in appCol)
            {
                appointments.Add(appt.Subject);
            }*/
            return appCol;
        }

        public bool addAppointment(string subject, DateTime dateStart, DateTime dateEnd)
        {
            Appointment appt = new Appointment();
            appt.Subject = subject;
            appt.Start = dateStart;
            appt.End = dateEnd;
            try
            {
                _appSession.Appointments.Items.Add(appt);
                return true;
            }catch(System.NotSupportedException e){
                return false;
            }
        }
    }
}
